
function [sG dir] = suppression_3_inputs(G, H, V)
% SUPPRESSION_3_INPUTS
%
% description: 
%     Iterate trough all image pixels (excluding 1 pixel border conditions in
%     Pixels which don't have all of neighbours) in order to
%     suppress pixels which are not part of edges
%     this can be used if we want to ignore the diagonal coffecients otherwise we can judge using them 
%      minimum(D,H,V) will decide the direction of the edge
%     tan(teta)=(oppositeside/adjacentside) <tan(pi/8)=> horizontal edge 
%     tan(teta)=(oppositeside/adjacentside) >tan(3*pi/8)=> veritival edge 
%     otherwise the edge will be considered as 45 or -45 (diagonal)
%
% Input:
%     G, H, V,D1,D2  vertical, horizontal, diagonalx2 details after
%
% Output: 
%         sG:non maxima suppressed image magnitude
%         dir:edge direction of each pixel in sG
%
% Example : 
%        [sG dir] = suppression_4_inputs(G, H, V)
% 
% Created on:    2013-2-015 (Dragomir El Mezeni)
% Last revision: 2014-01-23 (Mohamed Marouf) 
% Notice:
% -This function should be later combined with suppression__inputs
% -method parameter should be passed too. 


 height = size(G, 1);
 width = size(G,2);
 dir = zeros(height,width);
 sG = zeros(height, width);
 
 for y = 2 : height - 1
   for x = 2 : width - 1
     pH = H(y,x);
     pV = V(y,x);        
     if (((abs(pH) > 0.4142*abs(pV)) && (abs(pH) < 2.41*abs(pV))) || ((abs(pV) > 0.4142*abs(pH)) && (abs(pV) < 2.41*abs(pH))))
        if (pH*pV < 0)
            edge_max = max([G(y-1, x+1), G(y,x), G(y+1, x-1)]); %diagonal -45 degrees
            dir(y,x)=3;
        else
            edge_max = max([G(y+1, x+1), G(y,x), G(y-1, x-1)]); %diagonal +45 degeers
            dir(y,x)=2;
        end                
     else
        if (abs(pH) > abs(pV))
            edge_max = max([G(y-1, x), G(y,x), G(y+1, x)]); %horizontal edge
            dir(y,x)=1;
        else
            edge_max = max([G(y, x-1), G(y,x), G(y, x+1)]); %vertical edge
            dir(y,x)=0;
        end
     end        
     if (G(y, x) == edge_max)
        sG(y, x) = edge_max;
     end       
            
   end   
 end


